<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout" layout:decorator="layout">
<head>
<title>积分商城管理</title>
</head>
<body>
<div layout:fragment="content">
	<div class="row">
		<div class="col-md-12">
			<div class="btn-group pull-right">
				<a href="index.html" th:href="@{/promotion/goods/list/}" id="sample_editable_1_new" class="btn green">返回<i class="fa fa-arrow-circle-o-left"></i></a>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-12">
			<h4 class="form-section">积分商城信息</h4>
				<form role="form" id="form" th:action="@{/promotion/goods/save}" th:object="${creditGoods}" method="post" class="form-horizontal">
					<input type="hidden" th:field="*{id}" />
					<div class="form-group" th:class="${#fields.hasErrors('creditGoodsName')}? 'form-group has-error' : 'form-group'">
						<label class="control-label col-md-3">名称<span class="required" aria-required="true">* </span></label>							
						<div class="col-md-4">
							<input type="text" class="form-control" placeholder="名称" th:field="*{creditGoodsName}"/>
							<span class="help-block" th:if="${#fields.hasErrors('creditGoodsName')}" th:errors="*{creditGoodsName}">名称不能为空</span>
						</div>
					</div>
					<!-- 
					<div class="form-group">
						<label class="control-label col-md-3">类型<span class="required" aria-required="true">* </span></label>
						<div class="col-md-9">
							<div class="radio-list"> 
							<label class="radio-inline" th:each="eachValue : ${creditTypes}"> 
							<span>
							<input th:field="*{creditType}" type="radio" name="creditType" th:value="${eachValue}" th:text="${eachValue.description}" id="credit_goods_type" />
							</span>
							</label>
							</div>
						</div>
					</div>
					 -->
					<div class="form-group">
						<label class="control-label col-md-3">享受优惠会员等级<span class="required" aria-required="true">* </span></label>
						<div class="col-md-5">
				            <div class="checkbox-list">
									<label class="checkbox-inline"
										th:each="data : ${userRanks}"> 
											<span><input
												th:field="*{UserRank}"  th:checked="${data.id}" type="checkbox" name="userRankID"
												th:value="${data.id}" th:text="${data.rankName}" id="userRankID"/>
											</span>
								    </label>
							</div>
						</div>
					</div>
                    <div class="form-group" th:class="${#fields.hasErrors('creditType')}? 'form-group has-error' : 'form-group'">
                        <label class="control-label col-md-3">类型<span class="required" aria-required="true">* </span></label>
                        <div class="col-md-6">
                            <div class="radio-list">
                                <label class="radio-inline" th:each="creditType : ${creditTypeValues}"><span><input type="radio" th:attr="id=${'radio_creditType_'+creditTypeStat.index}" name="radio_creditType" th:field="*{creditType}" th:text="${creditType.description}" th:value="${creditType}"/></span></label>
                                <span class="help-block" th:if="${#fields.hasErrors('creditType')}" th:errors="*{creditType}"></span>
                            </div>
                        </div>
                    </div>
					<div class="form-group" th:classappend="${#fields.hasErrors('startTime')}? 'has-error'">
						<label class="control-label col-md-3">开始时间<span class="required">* </span></label>							
						<div class="col-md-4">
							<input id="start_time" type="text" class="form-control" placeholder="开始时间" th:field="*{startTime}"/>
							<span class="help-block" th:if="${#fields.hasErrors('startTime')}" th:errors="*{startTime}"></span>
						</div>
					</div>
					<div class="form-group" th:classappend="${#fields.hasErrors('endTime')}? 'has-error'">
						<label class="control-label col-md-3">结束时间<span class="required">* </span></label>							
						<div class="col-md-4">
							<input id="end_time" type="text" class="form-control" placeholder="结束时间" th:field="*{endTime}"/>
							<span class="help-block" th:if="${#fields.hasErrors('endTime')}" th:errors="*{endTime}"></span>
						</div>
					</div>
					<div class="form-actions fluid">
						<div class="col-md-offset-3 col-md-9">
							<button type="submit" id="btn_submit" class="btn blue">提交</button>
						</div>
					</div>
				</form>		
			</div>
		</div>
	</div>
</body>
</html>
<script th:inline="javascript">
	/*<![CDATA[*/
		$("#start_time").click(function(){
			WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
		}).focus(function () {
            WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
        });
		$("#end_time").click(function(){
			WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
		}).focus(function () {
            WdatePicker({startDate:'%y-%M-01 00:00:00',dateFmt:'yyyy-MM-dd HH:mm:ss',alwaysUseStartDate:true,readOnly:true});
        });
	          
		$('#btn_search').click(function() {
			var _sn = $('#goodsSn').val();
    		BOSS.remoteCall('creditGoods/ajaxSearch',$('#selt_goodsType'),{goodsSn:_sn});
		});

    $(document).ready(function(){
        $("#form").validate({
            rules:{
                creditGoodsName:{
                    required:true,
                    maxlength:100
                },
                startTime : {
                    required:true
                },
                endTime : {
                    required:true
                },
                creditType :{
                    required:true
                },
                UserRank: {
                    required: true
                }

            }
        });
    });
	/*]]>*/
</script>